<!-- START SIGMA IMPORTS -->
<script src="../src/sigma.core.js"></script>
<script src="../src/conrad.js"></script>
<script src="../src/utils/sigma.utils.js"></script>
<script src="../src/utils/sigma.polyfills.js"></script>
<script src="../src/sigma.settings.js"></script>
<script src="../src/classes/sigma.classes.dispatcher.js"></script>
<script src="../src/classes/sigma.classes.configurable.js"></script>
<script src="../src/classes/sigma.classes.graph.js"></script>
<script src="../src/classes/sigma.classes.camera.js"></script>
<script src="../src/classes/sigma.classes.quad.js"></script>
<script src="../src/classes/sigma.classes.edgequad.js"></script>
<script src="../src/captors/sigma.captors.mouse.js"></script>
<script src="../src/captors/sigma.captors.touch.js"></script>
<script src="../src/renderers/sigma.renderers.canvas.js"></script>
<script src="../src/renderers/sigma.renderers.webgl.js"></script>
<script src="../src/renderers/sigma.renderers.svg.js"></script>
<script src="../src/renderers/sigma.renderers.def.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.nodes.def.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.nodes.fast.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.edges.def.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.edges.fast.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.edges.arrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.labels.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.hovers.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.nodes.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.curve.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.arrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.curvedArrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.curve.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.arrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.curvedArrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.extremities.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.utils.js"></script>
<script src="../src/renderers/svg/sigma.svg.nodes.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.edges.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.edges.curve.js"></script>
<script src="../src/renderers/svg/sigma.svg.labels.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.hovers.def.js"></script>
<script src="../src/middlewares/sigma.middlewares.rescale.js"></script>
<script src="../src/middlewares/sigma.middlewares.copy.js"></script>
<script src="../src/misc/sigma.misc.animation.js"></script>
<script src="../src/misc/sigma.misc.bindEvents.js"></script>
<script src="../src/misc/sigma.misc.bindDOMEvents.js"></script>
<script src="../src/misc/sigma.misc.drawHovers.js"></script>
<!-- END SIGMA IMPORTS -->
<div id="container">
  <style>
    #graph-container {
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      position: absolute;
    }
    #notice {
      bottom: 1em;
      right: 1em;
      position: absolute;
    }
    .hidden {
      display: none;
    }
  </style>
  <div id="graph-container"><div id="notice" class="hidden">layout in progress...</div></div>
</div>
<script src="../plugins/sigma.plugins.animate/sigma.plugins.animate.js"></script>
<script src="../plugins/sigma.layout.forceLink/worker.js"></script>
<script src="../plugins/sigma.layout.forceLink/supervisor.js"></script>
<script>
/**
 * Just a simple example to show how to use the sigma.layout.forceLink
 * plugin:
 *
 * A random graph is generated, such that its nodes are separated in some
 * distinct clusters. Each cluster has its own color, and the density of
 * links is stronger inside the clusters. So, we expect the algorithm to
 * regroup the nodes of each cluster.
 */
var i,
    s,
    o,
    N = 1000,
    E = 5000,
    C = 5,
    d = 0.5,
    cs = [],
    g;

g = {
      nodes: [
        {id: 'source', label: 'source', x: Math.random(), y: Math.random(), size: 1},
        {id: 'target', label: 'target', x: Math.random(), y: Math.random(), size: 1},
        {id: 'n1', label: 'n1', x: Math.random(), y: Math.random(), size: 1},
        {id: 'n2', label: 'n2', x: Math.random(), y: Math.random(), size: 1},
        {id: 'n3', label: 'n3', x: Math.random(), y: Math.random(), size: 1}
      ],
      edges: [
        {id: 'e0', source: 'n1', target: 'source'},
        {id: 'e1', source: 'n1', target: 'target'},
        {id: 'e3', source: 'n2', target: 'source'},
        {id: 'e4', source: 'n2', target: 'target'},
        {id: 'e5', source: 'n3', target: 'source'},
        {id: 'e6', source: 'n3', target: 'target'}
      ]
};

s = new sigma({
  graph: g,
  container: 'graph-container',
  settings: {
    animationsTime: 1500
  }
});

// Configure the ForceLink algorithm:
var fa = sigma.layouts.configForceLink(s, {
  worker: true,
  barnesHutOptimize: false,
  autoStop: true,
  background: true,
  easing: 'cubicInOut',
  alignNodeSiblings: true,
  nodeSiblingsScale: 1,
  nodeSiblingsAngleMin: 0.3
});

// Bind the events:
fa.bind('start interpolate stop', function(e) {
  console.log(e.type);
  var el = document.getElementById('notice');
  if (e.type === 'start') {
    el.className = '';
  }
  else if (e.type === 'interpolate') {
    el.className = 'hidden';
  }
});

// Start the ForceLink algorithm:
sigma.layouts.startForceLink();
</script>
